//
//  MASTableViewIntrinsicCell.m
//  MasonryExample
//
//  Created by 山刘 on 2020/6/12.
//  Copyright © 2020 山刘. All rights reserved.
//

#import "MASTableViewIntrinsicCell.h"
#import "MASExampleIntrinsicView.h"

@interface MASTableViewIntrinsicCell()
@property(nonatomic,strong) MASExampleIntrinsicView *intrsicView;
@end

@implementation MASTableViewIntrinsicCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.intrsicView = [[MASExampleIntrinsicView alloc] init];
        [self.contentView addSubview:self.intrsicView];
        [self.intrsicView makeConstraints:^(MASConstraintMaker *make) {
            //make.edges.equalTo(kPadding);
            make.left.right.top.bottom.equalTo(kPadding);
        }];
    }
    return self;
}
-(void)updateData{
    if (self.cellData.imgs && self.cellData.imgs.length > 0) {
        NSString *temptString = self.cellData.imgs;
        if ([[temptString substringFromIndex:temptString.length-1] isEqualToString:@","]) {
            temptString = [temptString substringToIndex:[temptString length]-1];
        }
        NSArray * imagesArr = [temptString componentsSeparatedByString:@","];
        [self.intrsicView setStairTitles:imagesArr];
        [self layoutIfNeeded];
        //[self setNeedsUpdateConstraints];
    }
    [super updateData];
}
@end
